/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alvaro
 */
@Entity
@Table(name = "public_relations")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PublicRelations.findAll", query = "SELECT p FROM PublicRelations p"),
    @NamedQuery(name = "PublicRelations.findByIdPublicRelationships", query = "SELECT p FROM PublicRelations p WHERE p.idPublicRelationships = :idPublicRelationships"),
    @NamedQuery(name = "PublicRelations.findByName", query = "SELECT p FROM PublicRelations p WHERE p.name = :name"),
    @NamedQuery(name = "PublicRelations.findByLastName", query = "SELECT p FROM PublicRelations p WHERE p.lastName = :lastName"),
    @NamedQuery(name = "PublicRelations.findByDni", query = "SELECT p FROM PublicRelations p WHERE p.dni = :dni"),
    @NamedQuery(name = "PublicRelations.findByPhone", query = "SELECT p FROM PublicRelations p WHERE p.phone = :phone"),
    @NamedQuery(name = "PublicRelations.findByPayPerCandidate", query = "SELECT p FROM PublicRelations p WHERE p.payPerCandidate = :payPerCandidate"),
    @NamedQuery(name = "PublicRelations.findByReferals", query = "SELECT p FROM PublicRelations p WHERE p.referals = :referals")})
public class PublicRelations implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_PUBLIC_RELATIONSHIPS")
    private Integer idPublicRelationships;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 60)
    @Column(name = "LAST_NAME")
    private String lastName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 9)
    @Column(name = "DNI")
    private String dni;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 14)
    @Column(name = "PHONE")
    private String phone;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "PAY_PER_CANDIDATE")
    private BigDecimal payPerCandidate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "REFERALS")
    private int referals;
    @JoinColumn(name = "USER", referencedColumnName = "ID_USER")
    @OneToOne(cascade = CascadeType.ALL, optional = false)
    private User user;

    public PublicRelations() {
    }

    public PublicRelations(Integer idPublicRelationships) {
        this.idPublicRelationships = idPublicRelationships;
    }

    public PublicRelations(Integer idPublicRelationships, String name, String lastName, String dni, String phone, BigDecimal payPerCandidate, int referals) {
        this.idPublicRelationships = idPublicRelationships;
        this.name = name;
        this.lastName = lastName;
        this.dni = dni;
        this.phone = phone;
        this.payPerCandidate = payPerCandidate;
        this.referals = referals;
    }

    public Integer getIdPublicRelationships() {
        return idPublicRelationships;
    }

    public void setIdPublicRelationships(Integer idPublicRelationships) {
        this.idPublicRelationships = idPublicRelationships;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getDni() {
        return dni;
    }

    public void setDni(String dni) {
        this.dni = dni;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public BigDecimal getPayPerCandidate() {
        return payPerCandidate;
    }

    public void setPayPerCandidate(BigDecimal payPerCandidate) {
        this.payPerCandidate = payPerCandidate;
    }

    public int getReferals() {
        return referals;
    }

    public void setReferals(int referals) {
        this.referals = referals;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPublicRelationships != null ? idPublicRelationships.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PublicRelations)) {
            return false;
        }
        PublicRelations other = (PublicRelations) object;
        if ((this.idPublicRelationships == null && other.idPublicRelationships != null) || (this.idPublicRelationships != null && !this.idPublicRelationships.equals(other.idPublicRelationships))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.PublicRelations[ idPublicRelationships=" + idPublicRelationships + " ]";
    }
    
}
